<?php
// +----------------------------------------------------------------------
// | author: admin
// +----------------------------------------------------------------------

namespace app\common\model\travel;


use app\common\enum\StatusEnum;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use app\common\model\user\User;
use MyCLabs\Enum\Enum;


/**
 * Line模型
 * Class Line
 * @package app\common\model\travel
 */
class Line extends BaseModel
{

    protected $name = 'line';

    /**
     * @notes 获取器-旅行社
     * @param $value
     * @param $data
     * @return string|string[]
     */
    public function getTravelAgencyNameAttr($value, $data)
    {
        return TravelAgency::where('id', $data['travel_agency_id'])->value('name');
    }

    public function getUserAccountAttr($value, $data)
    {
        return User::where('id', $data['user_id'])->value('account');
    }

    public function getIsHotValueAttr($value, $data)
    {
        return DictData::where('type_value', 'is_hot')->where('value',$data['is_hot'])->value('name');
    }

    public function getStatusValueAttr($value, $data)
    {
        return DictData::where('type_value', 'approval_status')->where('value',$data['status'])->value('name');
    }

    public function getStatusRemarkAttr($value, $data)
    {
        return DictData::where('type_value', 'approval_status')->where('value',$data['status'])->value('remark');
    }

    public function getPendingStatusAttr($value, $data)
    {
        $count = LinePrice::where('line_id', $data['id'])->where('status',StatusEnum::PENDING)->count();
        if($count > 0)
        {
            return 1;
        }else{
            return 0;
        }
    }


}